<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>测试网页和原生通信</title>
  <style>
    .avatar {
        width: 300px;
        height: 300px;
        border-radius: 50%;
    }
  </style>
</head>

<body>
<h1>测试通信</h1>
<button id="btn1">测试弹出</button>
<button id="btnPhoto">拍照</button>
<button id="btnSelect">选择相册</button>
<img class="avatar" src="" alt="">

<script>
  document.querySelector("#btn1").addEventListener("click", () => {
      // window.hdm.showMessage("我成功了")
      const user = hdm.getUser() // 获取用户信息
      hdm.showMessage(JSON.stringify(user)) // 弹出消息
  })

  function changeH1(name) {
      document.querySelector("h1").innerText = name
  }
  document.querySelector("#btnPhoto").addEventListener("click", async () => {
      const url = await hdm.takePicture()
      document.querySelector(".avatar").src = url
  })
  document.querySelector("#btnSelect").addEventListener("click", async () => {
      const url = await hdm.selectPicture()
      document.querySelector(".avatar").src = url
  })


</script>
</body>

</html>